package com.ruoyi.info.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.info.domain.FhInfoUsertask;
import com.ruoyi.info.service.IFhInfoUsertaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 用户完成任务控制Controller
 * 
 * @author ruoyi
 * @date 2024-11-25
 */
@RestController
@RequestMapping("/info/usertask")
public class FhInfoUsertaskController extends BaseController
{
    @Autowired
    private IFhInfoUsertaskService fhInfoUsertaskService;

    /**
     * 查询用户完成任务控制列表
     */
    @PreAuthorize("@ss.hasPermi('info:usertask:list')")
    @GetMapping("/list")
    public TableDataInfo list(FhInfoUsertask fhInfoUsertask)
    {
        startPage();
        List<FhInfoUsertask> list = fhInfoUsertaskService.selectFhInfoUsertaskList(fhInfoUsertask);
        return getDataTable(list);
    }

    /**
     * 导出用户完成任务控制列表
     */
    @PreAuthorize("@ss.hasPermi('info:usertask:export')")
    @Log(title = "用户完成任务控制", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FhInfoUsertask fhInfoUsertask) throws IOException {
        List<FhInfoUsertask> list = fhInfoUsertaskService.selectFhInfoUsertaskList(fhInfoUsertask);
        ExcelUtil<FhInfoUsertask> util = new ExcelUtil<FhInfoUsertask>(FhInfoUsertask.class);
        util.exportExcel(response, list, "用户完成任务控制数据");
    }

    /**
     * 获取用户完成任务控制详细信息
     */
    @PreAuthorize("@ss.hasPermi('info:usertask:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(fhInfoUsertaskService.selectFhInfoUsertaskById(id));
    }

    /**
     * 新增用户完成任务控制
     */
    @PreAuthorize("@ss.hasPermi('info:usertask:add')")
    @Log(title = "用户完成任务控制", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FhInfoUsertask fhInfoUsertask)
    {
        return toAjax(fhInfoUsertaskService.insertFhInfoUsertask(fhInfoUsertask));
    }

    /**
     * 修改用户完成任务控制
     */
    @PreAuthorize("@ss.hasPermi('info:usertask:edit')")
    @Log(title = "用户完成任务控制", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FhInfoUsertask fhInfoUsertask)
    {
        return toAjax(fhInfoUsertaskService.updateFhInfoUsertask(fhInfoUsertask));
    }

    /**
     * 删除用户完成任务控制
     */
    @PreAuthorize("@ss.hasPermi('info:usertask:remove')")
    @Log(title = "用户完成任务控制", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fhInfoUsertaskService.deleteFhInfoUsertaskByIds(ids));
    }
}
